package com.sxdx.controller;

import com.sxdx.common.Result;
import com.sxdx.convert.BookConvert;
import com.sxdx.entity.Book;
import com.sxdx.entity.dto.BookDto;
import com.sxdx.service.IBookService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/bookOperation")
public class BookOperation {
    @Resource
    private IBookService service;

    /**
     * 图书增加
     * @param bookDto
     * @return
     */
    @RequestMapping("addBook")
    public Result<?> addBook( BookDto bookDto){

        return service.addBook(bookDto);
    }

    /**
     * 图书分页查询
     * @param currentPage
     * @param pageSize
     * @param searchByName
     * @return
     */
    @RequestMapping("searchBook")
    public Result<?> searchBook(Integer currentPage,Integer pageSize,String searchByName){
        return service.searchBook(currentPage, pageSize, searchByName);
    }

    @RequestMapping("deleteBook")
    public Result<?> deleteBook(String uuid){
        return service.deleteBook(uuid);
    }

    @RequestMapping("updateBook")
    public Result<?> updateBook(BookDto bookDto){
        return service.updateBook(bookDto);
    }
}
